.ai-chat-page {
  height: calc(100vh - 136px); // 减去头部和底部的高度
  overflow: hidden;
  border: 1px solid rgba(102, 126, 234, 0.15);
  border-radius: 12px;

  .chat-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
    border-radius: 12px;
  }

  // 头部区域
  .chat-header {
    flex-shrink: 0;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 255, 0.95) 100%);
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
    border-radius: 12px 12px 0 0; // 上边圆角
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;

    &::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 2px;
      background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #667eea 100%);
      background-size: 200% 100%;
      animation: shimmer 3s ease-in-out infinite;
    }

    .header-left {
      display: flex;
      align-items: center;
      gap: 16px;

      .title-icon {
        font-size: 24px;
        color: #667eea;
      }

      .title-text {
        font-size: 20px;
        font-weight: 700;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
      }

      :global(.ant-tag) {
        margin: 0;
      }
    }

    .header-right {
      display: flex;
      align-items: center;
      gap: 16px;
    }
  }

  // 消息区域 - 核心滚动区域
  .messages-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(248, 250, 255, 0.8) 0%, rgba(255, 255, 255, 0.9) 100%);

    .messages-scroll {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      overflow-y: scroll;
      overflow-x: hidden;
      padding: 24px 16px 24px 24px;

      // 强制显示滚动条
      scrollbar-width: auto;
      scrollbar-color: #667eea rgba(102, 126, 234, 0.1);

      &::-webkit-scrollbar {
        width: 14px;
        background: rgba(248, 250, 255, 0.5);
      }

      &::-webkit-scrollbar-track {
        background: rgba(102, 126, 234, 0.12);
        border-radius: 7px;
        margin: 8px 0;
        border: 1px solid rgba(102, 126, 234, 0.15);
      }

      &::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
        border-radius: 7px;
        border: 3px solid rgba(255, 255, 255, 0.5);
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);

        &:hover {
          background: linear-gradient(180deg, #5568d3 0%, #6a3f8f 100%);
          box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        }

        &:active {
          background: linear-gradient(180deg, #4a5bc4 0%, #5a3580 100%);
        }
      }
    }
  }

  // 消息项
  .message-item {
    margin-bottom: 32px;
    display: flex;
    gap: 12px;
    animation: messageSlideIn 0.4s ease-out;

    &.user {
      flex-direction: row-reverse;

      .message-bubble {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
      }
    }

    &.assistant {
      .message-bubble {
        background: white;
        padding: 30px 36px;
        color: rgba(0, 0, 0, 0.85);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
        border: 1px solid rgba(102, 126, 234, 0.1);
      }
    }

    .message-avatar {
      flex-shrink: 0;

      :global(.ant-avatar) {
        width: 44px;
        height: 44px;
        font-size: 20px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      }
    }

    .message-content {
      flex: 0 1 auto;
      max-width: 70%;
      min-width: 200px;
    }

    .message-header {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 8px;
      font-size: 13px;

      .message-role {
        font-weight: 600;
        color: rgba(0, 0, 0, 0.75);
      }

      .message-time {
        color: rgba(0, 0, 0, 0.45);
        font-size: 12px;
        margin-right: auto;
      }

      .copy-btn,
      .delete-btn {
        opacity: 0;
        transition: all 0.2s;

        &:hover {
          transform: scale(1.1);
        }
      }

      .copy-btn:hover {
        color: #667eea;
      }

      .delete-btn:hover {
        color: #ff4d4f;
      }
    }

    &:hover {
      .copy-btn,
      .delete-btn {
        opacity: 1;
      }
    }

    .message-bubble {
      padding: 12px 14px;
      border-radius: 12px;
      line-height: 1.7;
      word-wrap: break-word;
      word-break: break-word;
      font-size: 15px;
      max-width: 100%;
      transition: transform 0.2s, box-shadow 0.2s;

      &:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12) !important;
      }

      // 内容区域增加间距
      > * {
        &:first-child {
          margin-top: 0 !important;
        }
        &:last-child {
          margin-bottom: 0 !important;
        }
      }

      // 思考块样式
      .think-block {
        background: rgba(250, 173, 20, 0.08);
        border-left: 3px solid #faad14;
        padding: 12px 16px;
        margin: 12px 0;
        border-radius: 8px;
        transition: all 0.3s;

        summary {
          cursor: pointer;
          font-weight: 600;
          color: #d48806;
          user-select: none;
          padding: 4px 0;
          display: flex;
          align-items: center;
          gap: 8px;

          &:hover {
            color: #faad14;
          }

          .streaming-dot {
            font-size: 20px;
            line-height: 1;
            animation: streamingDot 1.5s infinite;
          }
        }

        .think-content {
          margin-top: 8px;
          padding-top: 8px;
          border-top: 1px dashed rgba(212, 136, 6, 0.3);
          color: rgba(0, 0, 0, 0.75);
          font-size: 14px;
        }

        // 流式输出中的 think 块
        &.think-streaming {
          border-left-color: #faad14;
          animation: thinkPulse 2s ease-in-out infinite;
        }
      }

      // 思考块脉冲动画
      @keyframes thinkPulse {
        0%, 100% {
          background: rgba(250, 173, 20, 0.08);
          box-shadow: 0 0 0 0 rgba(250, 173, 20, 0.2);
        }
        50% {
          background: rgba(250, 173, 20, 0.12);
          box-shadow: 0 0 10px 0 rgba(250, 173, 20, 0.3);
        }
      }

      // 流式输出点动画
      @keyframes streamingDot {
        0%, 20% {
          opacity: 0.2;
        }
        50% {
          opacity: 1;
        }
        100% {
          opacity: 0.2;
        }
      }

      // Markdown 样式优化
      :global {
        // 段落
        p {
          margin: 0 0 16px;
          line-height: 1.8;

          &:last-child {
            margin-bottom: 0;
          }

          &:first-child {
            margin-top: 0;
          }
        }

        // 标题
        h1, h2, h3, h4, h5, h6 {
          margin: 24px 0 16px;
          font-weight: 600;
          line-height: 1.4;
          color: #1a1a1a;

          &:first-child {
            margin-top: 0;
          }
        }

        h1 {
          font-size: 1.8em;
          padding-bottom: 12px;
          border-bottom: 2px solid rgba(102, 126, 234, 0.15);
        }

        h2 {
          font-size: 1.5em;
          padding-bottom: 8px;
          border-bottom: 1px solid rgba(102, 126, 234, 0.1);
        }

        h3 {
          font-size: 1.3em;
          color: #667eea;
        }

        h4 {
          font-size: 1.1em;
        }

        // 行内代码
        code {
          background: rgba(102, 126, 234, 0.08);
          color: #667eea;
          padding: 3px 8px;
          border-radius: 4px;
          font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
          font-size: 0.9em;
          font-weight: 500;
        }

        // 代码块
        pre {
          background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
          padding: 16px 20px;
          border-radius: 8px;
          overflow-x: auto;
          margin: 16px 0;
          border: 1px solid rgba(0, 0, 0, 0.1);
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);

          code {
            background: none;
            color: #e2e8f0;
            padding: 0;
            font-weight: normal;
          }
        }

        // 列表
        ul, ol {
          margin: 20px 0;
          padding-left: 32px;
          line-height: 1.8;

          &:first-child {
            margin-top: 8px;
          }

          &:last-child {
            margin-bottom: 8px;
          }

          li {
            margin: 10px 0;
            padding-left: 12px;

            &::marker {
              color: #667eea;
              font-weight: 600;
            }

            // 嵌套列表
            ul, ol {
              margin: 12px 0;
            }
          }
        }

        // 无序列表样式
        ul {
          list-style-type: disc;

          ul {
            list-style-type: circle;

            ul {
              list-style-type: square;
            }
          }
        }

        // 有序列表样式
        ol {
          list-style-type: decimal;

          ol {
            list-style-type: lower-alpha;

            ol {
              list-style-type: lower-roman;
            }
          }
        }

        // 引用块
        blockquote {
          border-left: 4px solid #667eea;
          padding: 12px 16px;
          margin: 16px 0;
          background: rgba(102, 126, 234, 0.05);
          border-radius: 4px;
          color: rgba(0, 0, 0, 0.75);
          font-style: italic;

          p {
            margin: 8px 0;

            &:first-child {
              margin-top: 0;
            }

            &:last-child {
              margin-bottom: 0;
            }
          }
        }

        // 链接
        a {
          color: #667eea;
          text-decoration: none;
          font-weight: 500;
          border-bottom: 1px solid transparent;
          transition: all 0.2s;

          &:hover {
            border-bottom-color: #667eea;
          }
        }

        // 表格
        table {
          border-collapse: collapse;
          width: 100%;
          margin: 16px 0;
          border: 1px solid rgba(102, 126, 234, 0.1);
          border-radius: 8px;
          overflow: hidden;

          thead {
            background: rgba(102, 126, 234, 0.08);

            th {
              font-weight: 600;
              color: #1a1a1a;
            }
          }

          th, td {
            padding: 12px 16px;
            border: 1px solid rgba(102, 126, 234, 0.1);
            text-align: left;
          }

          tr:hover {
            background: rgba(102, 126, 234, 0.03);
          }
        }

        // 水平线
        hr {
          border: none;
          border-top: 2px solid rgba(102, 126, 234, 0.1);
          margin: 24px 0;
        }

        // 强调
        strong, b {
          font-weight: 600;
          color: #1a1a1a;
        }

        em, i {
          font-style: italic;
          color: rgba(0, 0, 0, 0.75);
        }

        // 删除线
        del {
          text-decoration: line-through;
          color: rgba(0, 0, 0, 0.45);
        }
      }
    }
  }

  // 空状态
  .empty-state {
    padding: 80px 40px;
    text-align: center;

    .empty-title {
      font-size: 18px;
      font-weight: 600;
      color: #667eea;
      margin-bottom: 8px;
    }

    .empty-desc {
      color: rgba(0, 0, 0, 0.45);
      font-size: 14px;
    }
  }

  // 加载状态
  .loading-state {
    padding: 40px;
    text-align: center;

    :global(.ant-spin-text) {
      color: #667eea;
      font-weight: 500;
      margin-top: 12px;
    }
  }

  // 输入区域
  .input-area {
    flex-shrink: 0;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 255, 0.95) 100%);
    border-top: 1px solid rgba(102, 126, 234, 0.1);
    border-radius: 0 0 12px 12px; // 下边圆角

    .input-wrapper {
      :global(.ant-input) {
        border-radius: 12px;
        font-size: 16px;
        padding: 12px 16px;
        border: 2px solid rgba(102, 126, 234, 0.1);
        transition: all 0.3s;

        &:hover {
          border-color: #667eea;
        }

        &:focus {
          border-color: #667eea;
          box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        &::placeholder {
          color: rgba(102, 126, 234, 0.4);
        }
      }
    }

    .input-actions {
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      margin-top: 12px;

      :global(.ant-btn) {
        border-radius: 10px;
        height: 40px;
        padding: 0 24px;
        font-weight: 500;
        transition: all 0.3s;

        &.ant-btn-primary {
          background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
          border: none;
          box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);

          &:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
          }

          &:active {
            transform: translateY(0);
          }
        }

        &.ant-btn-dangerous {
          background: linear-gradient(135deg, #ff4d4f 0%, #cf1322 100%);
          color: white;
          border: none;

          &:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(255, 77, 79, 0.4);
          }
        }
      }
    }
  }

  // 动画
  @keyframes messageSlideIn {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes shimmer {
    0%, 100% {
      background-position: 0% 50%;
    }
    50% {
      background-position: 100% 50%;
    }
  }

  // 响应式
  @media (max-width: 1200px) {
    .message-item .message-content {
      max-width: 80%;
    }
  }

  @media (max-width: 768px) {
    padding: 8px;
    height: calc(100vh - 100px);

    .chat-header {
      padding: 16px 20px;
      flex-wrap: wrap;
      gap: 12px;
    }

    .messages-area .messages-scroll {
      padding: 20px 16px;
    }

    .message-item .message-content {
      max-width: 85%;
      min-width: 150px;
    }

    .input-area {
      padding: 16px 20px;
    }
  }

  @media (min-width: 1440px) {
    .message-item .message-content {
      max-width: 65%;
    }
  }
}
